package logic

import (
	"context"
	"zf/zfrpc/zfrpc"

	"zf/api/internal/svc"
	"zf/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UGoodHomeAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUGoodHomeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UGoodHomeAddLogic {
	return &UGoodHomeAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UGoodHomeAddLogic) UGoodHomeAdd(req *types.GoodHomeAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.ZfRpc.GoodHomeAdd(l.ctx, &zfrpc.GoodHomeAddRequest{
		Name:    req.Name,
		Status:  req.Status,
		Image:   req.Image,
		Address: req.Address,
		Info:    req.Info,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "商家入驻成功",
		Data:    add,
		Code:    200,
	}, nil

}
